﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ActionClass_Add :BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        UserPower.CheckAction((int)FreeHouse.Power.Actions.TActionClass.Add);
    }
    protected void save_Click(object sender, EventArgs e)
    {
        error.Items.Clear();
        FreeHouse.Model.TActionClass model = new FreeHouse.Model.TActionClass();
        model.ClassName = ActionClassName.Text.Trim();
        model.Description = Server.HtmlEncode(Description.Text);

        if (model.ClassName == "")
            error.Items.Add(new ListItem("填写:ActionClassName"));
        //if (model.Description == "")
        //    error.Items.Add(new ListItem("填写:Description"));
        if (error.Items.Count == 0)
        {
            //判断ActionClassName是否存在
            FreeHouse.BLL.TActionClass bll = new FreeHouse.BLL.TActionClass();
            if (bll.Exists(model.ClassName))
            {
                error.Items.Add(new ListItem("ActionClassName:" + model.ClassName + "已存在."));
            }
            else
            {
                if (bll.Add(model) > 0)
                {
                    Response.Write("<Script>alert('添加成功.');location.href='add.aspx';</script>");
                    //ActionClassName.Text = string.Empty;
                    //Description.Text = string.Empty;
                    Response.End();
                }
            }

        }

    }
}
